home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / editors / emcs1857 / 1857sr~1.zoo / lisp / rot13.el < prev    next >
Encoding:
Text File  |  1992-01-24  |  2.1 KB  |  68 lines

  1. ;; Display a buffer in rot13.
  2. ;; Copyright (C) 1987 Free Software Foundation, Inc.
  3.  
  4. ;; This file is part of GNU Emacs.
  5.  
  6. ;; GNU Emacs is distributed in the hope that it will be useful,
  7. ;; but WITHOUT ANY WARRANTY.  No author or distributor
  8. ;; accepts responsibility to anyone for the consequences of using it
  9. ;; or for whether it serves any particular purpose or works at all,
  10. ;; unless he says so in writing.  Refer to the GNU Emacs General Public
  11. ;; License for full details.
  12.  
  13. ;; Everyone is granted permission to copy, modify and redistribute
  14. ;; GNU Emacs, but only under the conditions described in the
  15. ;; GNU Emacs General Public License.   A copy of this license is
  16. ;; supposed to have been given to you along with GNU Emacs so you
  17. ;; can know your rights and responsibilities.  It should be in a
  18. ;; file named COPYING.  Among other things, the copyright notice
  19. ;; and this notice must be preserved on all copies.
  20.  
  21.  
  22. ;; Written by Howard Gayle.  See case-table.el for details.
  23.  
  24. ;; This hack is mainly to show off the char table stuff.
  25.  
  26. (defvar rot13-char-table nil "Char table for rot 13 display.")
  27.  
  28. (if rot13-char-table nil
  29.    (setq rot13-char-table (copy-char-table))
  30.    (let* (
  31.      (i ?A)       ; Current character.
  32.      (j (+ i 13)) ; Rotated character.
  33.      )
  34.       (while (<= i ?Z)
  35.      (put-char-table-dispr rot13-char-table j
  36.         (get-char-table-dispr (default-value 'buffer-char-table) i))
  37.      (setq i (1+ i))
  38.      (setq j (if (= j ?Z) ?A (1+ j)))
  39.       )
  40.       (setq i ?a)
  41.       (setq j (+ i 13))
  42.       (while (<= i ?z)
  43.      (put-char-table-dispr rot13-char-table j
  44.         (get-char-table-dispr (default-value 'buffer-char-table) i))
  45.      (setq i (1+ i))
  46.      (setq j (if (= j ?z) ?a (1+ j)))
  47.       )
  48.    )
  49. )
  50.  
  51. (defun rot13-other-window ()
  52.    "Display current buffer in rot 13 in another window."
  53.    (interactive)
  54.    (if (one-window-p t) (split-window-vertically))
  55.    (let     (
  56.            (w (get-lru-window))
  57.            )
  58.       (save-excursion
  59.            (beginning-of-line)
  60.      (set-window-buffer w (current-buffer))
  61.      (set-window-start w (point) t)
  62.      (set-window-char-table rot13-char-table w)
  63.       )
  64.    )
  65. )
  66.  
  67. (provide 'rot13)
  68.